<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
// 文件打印方法
// 应用公共文件
if (!function_exists('encode')) {
    /**
     * @title 用3des加密数据
     * @description 用3des加密数据
     * @author Admin ldy
     * @param name:$content  type:string require:1 default:1 desc:需要加密的数据
     * @time 2018/12/29  15:15
     * @return string
     */
    function encode($content)
    {
        $des = new \app\common\library\DES3();
        return $des->encrypt(null,$content);
    }
}

if (!function_exists('decode')) {
    /**
     * @title 用3des解密数据
     * @description 用3des解密数据
     * @author Admin ldy
     * @param name:$content  type:string require:1 default:1 desc:需要解密的数据
     * @time 2018/12/29  15:15
     * @return string
     */
    function decode($content)
    {
        $des = new \app\common\library\DES3();
        return $des->decrypt(null,$content);
    }
}

if (!function_exists('func_substr_replace')){
    // 隐藏部分字符串

    function func_substr_replace($str, $replacement = '*', $start = 1, $length = 4)

    {

        $len = mb_strlen($str,'utf-8');

        if ($len > intval($start+$length)) {

            $str1 = mb_substr($str,0,$start,'utf-8');

            $str2 = mb_substr($str,intval($start+$length),NULL,'utf-8');

        } else {

            $str1 = mb_substr($str,0,1,'utf-8');

            $str2 = mb_substr($str,$len-1,1,'utf-8');

            $length = $len - 2;

        }

        $new_str = $str1;

        for ($i = 0; $i < $length; $i++) {

            $new_str .= $replacement;

        }

        $new_str .= $str2;



        return $new_str;

    }
}